package com.rraj.common.mq.test.constant;

/**
 * CID枚举 一个CID对应一个枚举
 * 注意：每个CID注释请写清楚对应的TOPIC、TAG
 *
 * @author WangSheng
 * @date 2017/06/19
 */
public enum MQTestConsumerEnum {
    /**
     * TOPIC：TOPIC_DEFAULT_TEST_TOPIC1
     * TAG：TAG_DEFAULT_TEST_TOPIC1_SYNC、TAG_DEFAULT_TEST_TOPIC1_ASYNC、
     *         TAG_DEFAULT_TEST_TOPIC1_ONEWAY、TAG_DEFAULT_TEST_TOPIC1_TIMING、TAG_DEFAULT_TEST_TOPIC1_DELAY
     */
    CONSUMER_DEFAULT_TEST_CID1(1, "CONSUMER_DEFAULT_TEST_CID1", "CLUSTERING", "CID_RENREN_TEST_CID1", "测试集群普通消费者1"),
    /**
     * TOPIC：TOPIC_DEFAULT_TEST_TOPIC1
     * TAG：TAG_DEFAULT_TEST_TOPIC1_SYNC、TAG_DEFAULT_TEST_TOPIC1_ASYNC、
     *         TAG_DEFAULT_TEST_TOPIC1_ONEWAY、TAG_DEFAULT_TEST_TOPIC1_TIMING、TAG_DEFAULT_TEST_TOPIC1_DELAY
     */
    CONSUMER_DEFAULT_TEST_CID2(1, "CONSUMER_DEFAULT_TEST_CID2", "BROADCASTING", "CID_RENREN_TEST_CID2", "测试广播普通消费者1"),
    /**
     * TOPIC：TOPIC_TRANSACTION_TEST_TOPIC1
     * TAG：TAG_TRANSACTION_TEST_TOPIC1_TAG1
     */
    CONSUMER_TRANSACTION_TEST_CID1(1, "CONSUMER_TRANSACTION_TEST_CID1", "CLUSTERING", "CID_RENREN_TEST_TRANSACTION_CID1", "测试事务消费者1"),
    /**
     * TOPIC：TOPIC_ALL_ORDER_TEST_TOPIC1
     * TAG：TAG_ALL_ORDER_TEST_TOPIC1_TAG1
     */
    CONSUMER_ALL_ORDER_TEST_CID1(1, "CONSUMER_ALL_ORDER_TEST_CID1", "CLUSTERING", "CID_RENREN_TEST_ALL_ORDER_CID1", "测试全局顺序消费者1"),
    /**
     * TOPIC：TOPIC_SHARDING_ORDER_TEST_TOPIC1
     * TAG：TAG_SHARDING_ORDER_TEST_TOPIC1_TAG1
     */
    CONSUMER_SHARDING_ORDER_TEST_CID1(1, "CONSUMER_SHARDING_ORDER_TEST_CID1", "CLUSTERING", "CID_RENREN_TEST_FENQU_ORDER_CID1", "测试分区顺序消费者1");

    /**
     * 唯一标识
     */
    private int id;
    /**
     * 枚举的键
     * 命名格式：CID_CONSUMER名称
     */
    private String code;
    /**
     * 消费方式
     * CLUSTERING:集群消费 、BROADCASTING:广播消费
     */
    private String mode;
    /**
     * CID
     */
    private String cid;
    /**
     * 描述
     */
    private String desc;

    MQTestConsumerEnum(int id, String code, String mode, String cid, String desc) {
        this.id = id;
        this.code = code;
        this.mode = mode;
        this.cid = cid;
        this.desc = desc;
    }

    public static MQTestConsumerEnum getEnumById(int id) {
        for (MQTestConsumerEnum c : MQTestConsumerEnum.values()) {
            if (c.getId() == id) {
                return c;
            }
        }
        return null;
    }
    public static MQTestConsumerEnum getEnumByCode(String code) {
        for (MQTestConsumerEnum c : MQTestConsumerEnum.values()) {
            if (c.getCode().equals(code)) {
                return c;
            }
        }
        return null;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMode() {
        return mode;
    }

    public void setMode(String mode) {
        this.mode = mode;
    }

    public String getCid() {
        return cid;
    }

    public void setCid(String cid) {
        this.cid = cid;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
}
